home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Portable Parts / Patterns / PatternMatcher.cp < prev    next >
Encoding:
Text File  |  2000-06-23  |  584 b   |  26 lines

  1. // PatternMatcher.cp
  2.  
  3. #ifndef PatternMatcher_h
  4. #include "PatternMatcher.h"
  5. #endif
  6. #ifndef Overflow_h
  7. #include "Overflow.h"
  8. #endif
  9.  
  10. void PatternMatcher::SetTarget( ConstData theTarget )
  11.   {
  12.     Assert( theTarget.Length() > 0 );
  13.     
  14.     target = theTarget;
  15.     
  16.     uint8 largestAdvance = ( theTarget.Length() < maxuint8 )
  17.                                   ? Asuint8( theTarget.Length() )
  18.                                   : maxuint8;
  19.     
  20.     for ( uint32 c = 0; c <= maxuint8; c++ )
  21.         advance[c] = largestAdvance;
  22.     
  23.     for ( uint8 distance = largestAdvance - 1; distance > 0; distance-- )
  24.         advance[ *( theTarget.End() - 1 - distance ) ] = distance;
  25.   }
  26.